﻿<Window xmlns:my="clr-namespace:YLClient.UserControls"  x:Class="YLClient.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
        xmlns:primitives="clr-namespace:Microsoft.Windows.Controls.Primitives;assembly=WPFToolkit"
        xmlns:vsm="clr-namespace:System.Windows;assembly=WPFToolkit"
        xmlns:src="clr-namespace:YLClient.RedLetterDays"
        Title="影楼端" WindowStartupLocation="CenterScreen" 
        Closed="Window_Closed" MinHeight="350" MaxHeight="800" MinWidth="500" mc:Ignorable="d" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        d:DesignHeight="538" d:DesignWidth="527" SizeToContent="WidthAndHeight">
    <Grid>
        <DockPanel   VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="Auto" Width="Auto">
            <Menu DockPanel.Dock="Top" Height="23" HorizontalAlignment="Stretch" Margin="0" Name="menu1" VerticalAlignment="Top" Width="Auto">
                <MenuItem Header="设置" Click="Setting_Click" />
                <MenuItem Header="帐户">
                    <MenuItem Name="getUserAccount" Header="获取帐户信息" Click="getUserAccount_Click" />
                </MenuItem>
                <MenuItem Header="帮助" />
            </Menu>
            <ToolBarPanel  DockPanel.Dock="Top" Orientation="Horizontal">
                <Button Name="Add" Content="添加一份" Click="Add_Click" Margin="2" />
                <Button  Name="Download" Content="全部下载" Margin="2" ToolTip="下载所有当前所显示的" IsEnabled="False" />
                <Button Name="Search" Content="查询..." Margin="2" Click="Search_Click" />
            </ToolBarPanel>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <toolkit:Calendar 
                        Grid.Column="0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"  SelectedDatesChanged="Calendar_SelectedDatesChanged">
                    <toolkit:Calendar.CalendarDayButtonStyle>

                        <!-- This is mostly copied from generic.xaml -->

                        <Style TargetType="primitives:CalendarDayButton">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="primitives:CalendarDayButton">

                                        <!-- This is new -->
                                        <ControlTemplate.Resources>
                                            <src:RedLetterDayConverter x:Key="conv" />
                                        </ControlTemplate.Resources>

                                        <Grid ToolTip="{Binding Converter={StaticResource conv}, 
                                                    Mode=OneWay}">

                                            <!-- Resume the copy -->

                                            <vsm:VisualStateManager.VisualStateGroups>
                                                <vsm:VisualStateGroup x:Name="CommonStates">
                                                    <vsm:VisualStateGroup.Transitions>
                                                        <vsm:VisualTransition GeneratedDuration="0:0:0.1" />
                                                    </vsm:VisualStateGroup.Transitions>
                                                    <vsm:VisualState x:Name="Normal" />
                                                    <vsm:VisualState x:Name="MouseOver">
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity" To=".5" Duration="0" />
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                    <vsm:VisualState x:Name="Pressed">
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity" To=".5" Duration="0" />
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                    <vsm:VisualState x:Name="Disabled">
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity" To="0" Duration="0" />
                                                            <DoubleAnimation Storyboard.TargetName="NormalText" Storyboard.TargetProperty="Opacity" To=".35" Duration="0" />
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                </vsm:VisualStateGroup>
                                                <vsm:VisualStateGroup x:Name="SelectionStates">
                                                    <vsm:VisualStateGroup.Transitions>
                                                        <vsm:VisualTransition GeneratedDuration="0" />
                                                    </vsm:VisualStateGroup.Transitions>
                                                    <vsm:VisualState x:Name="Unselected" />
                                                    <vsm:VisualState x:Name="Selected">
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetName="SelectedBackground" Storyboard.TargetProperty="Opacity" To=".75" Duration="0" />
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                </vsm:VisualStateGroup>
                                                <vsm:VisualStateGroup x:Name="CalendarButtonFocusStates">
                                                    <vsm:VisualStateGroup.Transitions>
                                                        <vsm:VisualTransition GeneratedDuration="0" />
                                                    </vsm:VisualStateGroup.Transitions>
                                                    <vsm:VisualState x:Name="CalendarButtonFocused">
                                                        <Storyboard>
                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DayButtonFocusVisual" Storyboard.TargetProperty="Visibility" Duration="0">
                                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                                    <DiscreteObjectKeyFrame.Value>
                                                                        <Visibility>Visible</Visibility>
                                                                    </DiscreteObjectKeyFrame.Value>
                                                                </DiscreteObjectKeyFrame>
                                                            </ObjectAnimationUsingKeyFrames>
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                    <vsm:VisualState x:Name="CalendarButtonUnfocused">
                                                        <Storyboard>
                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DayButtonFocusVisual" Storyboard.TargetProperty="Visibility" Duration="0">
                                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                                    <DiscreteObjectKeyFrame.Value>
                                                                        <Visibility>Collapsed</Visibility>
                                                                    </DiscreteObjectKeyFrame.Value>
                                                                </DiscreteObjectKeyFrame>
                                                            </ObjectAnimationUsingKeyFrames>
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                </vsm:VisualStateGroup>
                                                <vsm:VisualStateGroup x:Name="ActiveStates">
                                                    <vsm:VisualStateGroup.Transitions>
                                                        <vsm:VisualTransition GeneratedDuration="0" />
                                                    </vsm:VisualStateGroup.Transitions>
                                                    <vsm:VisualState x:Name="Active" />
                                                    <vsm:VisualState x:Name="Inactive">
                                                        <Storyboard>
                                                            <ColorAnimation Duration="0" Storyboard.TargetName="selectedText" Storyboard.TargetProperty="Color" To="#FF777777"></ColorAnimation>
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                </vsm:VisualStateGroup>
                                                <vsm:VisualStateGroup x:Name="DayStates">
                                                    <vsm:VisualStateGroup.Transitions>
                                                        <vsm:VisualTransition GeneratedDuration="0" />
                                                    </vsm:VisualStateGroup.Transitions>
                                                    <vsm:VisualState x:Name="RegularDay" />
                                                    <vsm:VisualState x:Name="Today">
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetName="TodayBackground" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                                            <ColorAnimation Duration="0" Storyboard.TargetName="selectedText" Storyboard.TargetProperty="Color" To="#FFFFFFFF"></ColorAnimation>
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                </vsm:VisualStateGroup>
                                                <vsm:VisualStateGroup x:Name="BlackoutDayStates">
                                                    <vsm:VisualStateGroup.Transitions>
                                                        <vsm:VisualTransition GeneratedDuration="0" />
                                                    </vsm:VisualStateGroup.Transitions>
                                                    <vsm:VisualState x:Name="NormalDay" />
                                                    <vsm:VisualState x:Name="BlackoutDay">
                                                        <Storyboard>
                                                            <DoubleAnimation Duration="0" Storyboard.TargetName="Blackout" Storyboard.TargetProperty="Opacity" To=".2"/>
                                                        </Storyboard>
                                                    </vsm:VisualState>
                                                </vsm:VisualStateGroup>
                                            </vsm:VisualStateManager.VisualStateGroups>
                                            <Rectangle x:Name="TodayBackground" RadiusX="1" RadiusY="1" Opacity="0" Fill="#FFAAAAAA"/>

                                            <!-- This element is new -->
                                            <Rectangle x:Name="RedLetterDayBackground" IsHitTestVisible="False" Fill="#80FF0000" />

                                            <Rectangle x:Name="SelectedBackground" RadiusX="1" RadiusY="1" Opacity="0" Fill="{TemplateBinding Background}"/>
                                            <Rectangle x:Name="Background" RadiusX="1" RadiusY="1" Opacity="0" Fill="{TemplateBinding Background}"/>
                                            <ContentPresenter
                                    x:Name="NormalText"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    Margin="5,1,5,1"
                                    >
                                                <TextElement.Foreground>
                                                    <SolidColorBrush x:Name="selectedText" Color="#FF333333"/>
                                                </TextElement.Foreground>
                                            </ContentPresenter>
                                            <Path x:Name="Blackout" Opacity="0" Margin="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Fill="#FF000000" Stretch="Fill" Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z"/>
                                            <Rectangle x:Name="DayButtonFocusVisual" Visibility="Collapsed" IsHitTestVisible="false" RadiusX="1" RadiusY="1" Stroke="#FF45D6FA"/>
                                        </Grid>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsFocused" Value="True">
                                                <Setter TargetName="DayButtonFocusVisual" Property="Visibility" Value="Visible" />
                                            </Trigger>

                                            <!-- This DataTrigger is new -->
                                            <DataTrigger Binding="{Binding Converter={StaticResource conv}}"
                                             Value="{x:Null}">
                                                <Setter TargetName="RedLetterDayBackground" 
                                            Property="Visibility" Value="Hidden" />
                                            </DataTrigger>

                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </toolkit:Calendar.CalendarDayButtonStyle>
                </toolkit:Calendar>
                <ListBox 
                    Grid.Column="1"
                    Name="lstItems" HorizontalContentAlignment="Stretch">
                </ListBox>
            </Grid>
        </DockPanel>
    </Grid>
</Window>

    